# -*- coding: utf-8 -*-
"""
10. 采集该站点10条数据，字段不限，地址：http://www.customs.gov.cn/customs/302427/302442/3495580/index.html，说明：禁止使用自动化等技术
"""
import feapder


class Demo101(feapder.AirSpider):
    def start_requests(self):
        form_data = {
            "__RequestVerificationToken": "wCxxzPyI9VRRNzgkohZsVzNxmHT8puU5f14NaLKB5C9Sm6kif55PJu3Vk91a1h0UN3mhysM4cfRcfrrX6zHnChBVz58iFWfbxyqy2R1DJf01",
            "page": "1",
            "pageSize": "20",
            "Type": "YCD",
            "SourceNo": "",
            "GName": "",
            "CodeTS": "",
            "GMdel": "",
            "EngName": "",
            "OtherName": ""
        }
        headers = {
            "Accept": "application/json, text/javascript, */*; q=0.01",
            "Accept-Encoding": "gzip, deflate",
            "Accept-Language": "zh-CN,zh;q=0.9",
            "Connection": "keep-alive",
            "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
            "Cookie": "__RequestVerificationToken_L0NMU291dGVyMjAyMA2=-eiGxNQOL6PsPHkm7Ak58BdByOz3Y-Y7JhCzoO1LwQ6hzG6lIGuDsS7fTV1b9Yx2xNGrSHt2aDxZ7w8jYDJjwa5666c3QE0Yzlt_HNif5zk1",
            "Host": "gss.customs.gov.cn",
            "Origin": "http://gss.customs.gov.cn",
            "Referer": "http://gss.customs.gov.cn/clsouter2020/Home/ClassifyYCDSearch",
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",
            "X-Requested-With": "XMLHttpRequest"
        }
        _url = "http://gss.customs.gov.cn/CLSouter2020/Search/GetQuerySearchList"
        yield feapder.Request(_url, method="POST", data=form_data, headers=headers)

    def parse(self, request, response):
        print("网站地址: ", response.url)
        for item in response.json["data"]:
            print(item)


if __name__ == "__main__":
    Demo101().start()